<!--
// 
// Count.vue
// hs-admin
// 
// 2024/10/28.
// 
-->
<template>
    <div class="Count" :style="styles.box">
        <g-flex v-if="layoutType === 'pc'" row justify-content-start align-items-center width="100%" height="100%">
            <g-flex row justify-content-center align-items-center width="60px" height="60px" :style="styles.icon" class="icon-container">
                <template v-if="item.bIcon">
                    <b-icon :name="item.icon" :size="item.iconSize"/>
                </template>
                <template v-else>
                    <el-icon :size="item.iconSize"><component :is="item.icon"></component></el-icon>
                </template>
            </g-flex>
            <g-flex column align-content-center align-items-center>
                <div class="value" :style="styles.value">{{item.value}}</div>
                <div class="title">{{item.title}}</div>
            </g-flex>
        </g-flex>
        <g-flex v-if="layoutType === 'mobile'" row justify-content-between align-items-center height="100%">
            <g-flex row justify-content-start align-items-center :style="styles.icon">
                <template v-if="item.bIcon">
                    <b-icon :name="item.icon" :size="item.iconSize - 20"/>
                </template>
                <template v-else>
                    <el-icon :size="item.iconSize - 20"><component :is="item.icon"></component></el-icon>
                </template>
                <div class="title">{{item.title}}</div>
            </g-flex>
            <div class="value" :style="styles.value">{{item.value}}</div>
        </g-flex>
    </div>
</template>

<script setup>
import {ref, reactive, computed, onMounted} from "vue";
import {useStore} from "vuex";

const props = defineProps({
    item: {
        type: Object,
    }
});
const emits = defineEmits();

// store
const store = useStore();
const layoutType = computed(() => store.getters.layoutType)
const styles = computed(() => {
    return {
        box: {
            borderColor: props.item.color,
        },
        icon: {
            color: props.item.color,
        },
        value: {
            color: props.item.color,
        },
    }
})


onMounted(() => {

})
</script>

<style scoped lang="scss">
@media (width > 1300px) {
    .Count {
        border-radius: 6px;
        background: #fff;
        padding: 0 30px;
        box-sizing: border-box;
        box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
        border: 1px solid #fff;
        border-left-width: 6px;

        width: calc(25% - 20px);
        height: 100px;
        margin-right: 20px;
        margin-bottom: 20px;

        .title {
            font-size: 18px;
            color: #333;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            padding-left: 10px;
            text-align: center;
            box-sizing: border-box;
            text-indent: -10px;
        }
        .value {
            font-size: 26px;
            font-weight: bold;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            padding-left: 10px;
            text-align: center;
            box-sizing: border-box;
            text-indent: -10px;
        }

    }
}

@media (800px < width <= 1300px) {
   .Count {
       width: calc(50% - 20px);
       height: 120px;
       background: #fff;
       margin-right: 20px;
       margin-bottom: 20px;
       border-radius: 6px;
       box-sizing: border-box;
       padding: 0 30px;
       box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
       border: 1px solid #fff;
       border-left-width: 6px;
       .title {
           font-size: 18px;
           color: #333;
           width: 100%;
           overflow: hidden;
           text-overflow: ellipsis;
           padding-left: 10px;
           text-align: center;
           box-sizing: border-box;
           text-indent: 0;
       }
       .value {
           font-size: 26px;
           font-weight: bold;
           width: 100%;
           overflow: hidden;
           text-overflow: ellipsis;
           padding-left: 10px;
           text-align: center;
           box-sizing: border-box;
           text-indent: 0;
       }
    }
}
@media (width <= 800px) {
   .Count {
       border-radius: 6px;
       width: 100%;
       height: unset;
       background: #fff;
       margin-right: 10px;
       margin-bottom: 10px;
       padding: 4px 10px;
       box-sizing: border-box;
       box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
       border: 1px solid #fff;
       border-left-width: 6px;
       .title {
           width: unset;
           font-size: 16px;
           color: #333;
           padding-left: 10px;
           text-align: left;
           box-sizing: border-box;
           text-indent: 0;
       }
       .value {
           width: unset;
           font-size: 20px;
           font-weight: bold;
           box-sizing: border-box;
           text-align: right;
           text-indent: 0;
       }
    }
}
</style>